from exts import db
from common.base_model import BaseModel, BasicModelMixin, CompanyMixin, CreateMixin, UpdateMixin
from common import constant
import datetime


class CouponCode(BasicModelMixin, db.Model, CreateMixin, UpdateMixin):
    __tablename__ = 'coupon_code'

    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(constant.MIDDLE_DB_STR_LEN))
    is_sale = db.Column(db.Boolean, default=False)
    is_used = db.Column(db.Boolean, default=False)
    coins = db.Column(db.Integer, default=constant.CouponCoinType.one)
    consumer_user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    consumer_user = db.relationship("User", foreign_keys='CouponCode.consumer_user_id')
